package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.UserCollect;
import cn.wolfcode.trip.base.domain.UserLike;
import cn.wolfcode.trip.base.service.ICollectService;
import cn.wolfcode.trip.base.service.ILikeService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CollectLikeController {

        @Autowired
        private ICollectService collectService;
        @Autowired
        private ILikeService likeService;


        //保存一条用户点赞
        @PostMapping("/likes/users/save")
        public Object saveLike(UserLike uc) {
            Integer likenums = likeService.save(uc);
            return likenums;
        }

        //查询点赞
        @GetMapping("/likes/users/get")
        public Object getLike(Long userId,Long likeId,Integer type) {
            UserLike userLike = likeService.get(userId, likeId, type);
            return userLike;
        }

        //删除点赞
        @PostMapping("/likes/users/delete")
        public Object deleteLike(Long userId,Long likeId,Integer type) {
            Integer likenums = likeService.delete(userId,likeId,type);
            return likenums;
        }



        //=================================================

        /**
         * 保存一条用户收藏
         * @param uc
         * @return
         */
        @PostMapping("/collects/users/save")
        public Object saveCollect(UserCollect uc) {
            Integer collectsNum =  collectService.save(uc);
            return collectsNum;
        }

        @GetMapping("/collects/users/get")
        public Object getCollect(Long userId,Long collectId,Integer type) {
            UserCollect userCollect = collectService.get(userId, collectId, type);
            return userCollect;
        }


        @PostMapping("/collects/users/delete")
        public Object deleteCollect(Long userId,Long collectId,Integer type) {
            Integer collectsNum = collectService.delete(userId, collectId, type);
            return collectsNum;
        }


}
